package net.lgpage.util;

import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.view.ViewGroup;

public  class  RecyclerViewFooterAdapter <ViewHolder extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<ViewHolder>{

	public static final int FOOT_TYPE = -2;
	RecyclerView.Adapter<ViewHolder>adp;
	RecyclerView.ViewHolder footer_h;
	
	
	
	public RecyclerView.Adapter<ViewHolder> getAdp() {
		return adp;
	}
	public void setAdp(RecyclerView.Adapter<ViewHolder> adp) {
		this.adp = adp;
	}
	public RecyclerView.ViewHolder getFooterViewHolder() {
		return footer_h;
	}
	public RecyclerViewFooterAdapter(Adapter<ViewHolder> adp) {
		super();
		this.adp = adp;
	}

	int viewcount;
	public void setFooterView(RecyclerView.ViewHolder fh){
		viewcount = 1;
		footer_h = fh;
	}
	@Override
	public int getItemCount() {
		return adp.getItemCount()+viewcount;
	}

	@Override
	public void onBindViewHolder(ViewHolder h, int position) {
		if(position<adp.getItemCount()){
			adp.onBindViewHolder(h, position);
		}else{
			
		}
	}
	

	@Override
	public int getItemViewType(int position) {
		if(position<adp.getItemCount()){
			return adp.getItemViewType(position);
		}else{
			return FOOT_TYPE;
		}
	}

	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		if(viewType == FOOT_TYPE){
			return (ViewHolder) footer_h;
		}else{
			return adp.createViewHolder(parent, viewType);
		}
	}

}
